﻿@using BankCreditPortfolio.DAL.Entities
@using BankCreditPortfolio.DAL.Services
@using MvcContrib.Pagination
@using MvcContrib.UI.Grid
@using MvcContrib.UI.Pager
@model BankCreditPortfolio.Areas.Admin.Models.ReportModel

@{
    ViewBag.Title = "Reports";
}

<h2>Reports</h2>

<h3>The bank payments list</h3>

    @{
        var depositService = new DepositService();
        if (Model.Credits.Count() > 0)
        {
            Html.Grid<Agreement>(Model.Credits).Columns(column =>
                {
                    column.For(x => depositService.GetBankDeposit(x.Order.Currency.Title).DepositId).Named("Start Deposit Id");
                    column.For(x => depositService.GetBankDeposit(x.Order.Currency.Title).DepositType.Title).Named("Start Deposit Type");
                    column.For(x => x.Credit.Deposit.DepositId).Named("Finish Deposit Identity");
                    column.For(x => x.Credit.Deposit.DepositType.Title).Named("Finish Type");
                    column.For(x => x.Credit.DeliveryDate.ToString("dd.MM.yyyy")).Named("Date");
                    column.For(x => x.Order.Amount).Named("Amount");
                    column.For(x => x.Order.Currency.Title).Named("Currency");
                    
                }).Render();
             <br />
            @Html.Pager(Model.Credits).First("First").Last("Last").Next("Next").Previous("Previous")
        }
        else
        {
            <div>There is no credits payments yeat.</div>
        }
    }
<p>
    <img src="@Url.Action("CreditChart", "Admin")" />
</p>
<h3>The client credit payments list</h3>

    @{
        if (Model.Payments.Count() > 0)
        {
            Html.Grid<Payment>(Model.Payments).Columns(column =>
                {
                    column.For(x => x.Deposit.DepositId).Named("Start Deposit Id");
                    column.For(x => x.Deposit.DepositType.Title).Named("Start Deposit Type");
                    column.For(x => depositService.GetBankDeposit(x.Currency.Title).DepositId).Named("Finish Deposit Id");
                    column.For(x => depositService.GetBankDeposit(x.Currency.Title).DepositType.Title).Named("Finish Deposit Type");
                    column.For(x => x.Date.ToString("dd.MM.yyyy")).Named("Date");
                    column.For(x => x.Amount).Named("Amount");
                    column.For(x => x.Currency.Title).Named("Currency");
                    
                }).Render();
             <br />
            @Html.Pager(Model.Payments).First("First").Last("Last").Next("Next").Previous("Previous")
        }
        else
        {
            <div>There is no payments for credits yet.</div>
        }
    }
    <p>
        <img src="@Url.Action("PaymentChart", "Admin")" />
</p>
<h3>The tariffs popularity chart</h3>
<p>
<img src="@Url.Action("TariffPopularityChart", "Admin")" />
</p>
<p>Please choose report type (generate XML reports)</p>
<div>
    <ul>
        <li>
            @Html.ActionLink("Get Payments report", "GetPaymentReport", "Admin")
        </li>
        <li>
            @Html.ActionLink("Get Credits report", "GetActiveCreditsReport", "Admin")
        </li>
    </ul>
</div>
